package com.stox.charting.ui.swing.model;

import java.awt.Graphics;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;

import com.stox.core.ui.swing.wrapper.JComponent;

public class Grid extends JComponent{
	private static final long serialVersionUID = -5861195318851694519L;

	private final List<Integer> verticalLines = new ArrayList<Integer>();
	private final List<Integer> horizontalLines = new ArrayList<Integer>();
	
	private int minimumHorizontalGap = 20;
	private int minimumVerticalGap = 20;
	
	public List<Integer> getVerticalLines() {
		return verticalLines;
	}
	public List<Integer> getHorizontalLines() {
		return horizontalLines;
	}
	
	@Override
	public void paintComponent(Graphics g){
		g.setColor(Theme.getColours().getGrid());
		Rectangle r = getVisibleRect();
		int y = (int)r.getY();
		int y1 = (int)(r.getY() + r.getHeight());
		for(int i : verticalLines){
			g.drawLine(i, y, i, y1);
		}
		int x = (int)r.getX();
		int x1 = (int)(r.getX()+r.getWidth());
		for(int i : horizontalLines){
			g.drawLine(x, i, x1, i);
		}
	}
	
	public int getMinimumHorizontalGap() {
		return minimumHorizontalGap;
	}
	public void setMinimumHorizontalGap(int minimumHorizontalGap) {
		this.minimumHorizontalGap = minimumHorizontalGap;
	}
	public int getMinimumVerticalGap() {
		return minimumVerticalGap;
	}
	public void setMinimumVerticalGap(int minimumVerticalGap) {
		this.minimumVerticalGap = minimumVerticalGap;
	}
	
}
